package com.android.DroidBookGallery.Utils;

import java.util.ArrayList;
import java.util.List;

import android.util.Pair;

public class URLComposer {
	
	private String endpoint;
	private final List<Pair<String, String>> params = new ArrayList<Pair<String, String>>();

	// @EstadoDevelop("testado")
	public String Endpoint() {
		return this.endpoint;
	}

	// @EstadoDevelop("testado")
	public URLComposer setEndpoint(String endpoint) {
		this.endpoint = endpoint;
		return this;
	}

	// @EstadoDevelop("testado")
	public URLComposer addParameter(String paramName, String paramValue) {
		params.add(new Pair<String, String>(paramName, paramValue));
		return this;
	}

	// @EstadoDevelop("testado")
	public List<Pair<String, String>> Params() {
		return this.params;
	}

	// @EstadoDevelop("testado")
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append(this.endpoint);
		if (params.size() > 0) {
			for (int i = 0; i < this.params.size(); i++) {
				if (i == 0) {
					builder.append("?");
				} else {
					builder.append("&");
				}
				builder.append(this.params.get(i).first);
				builder.append("=");
				builder.append(this.params.get(i).second);
			}
		}
		return builder.toString();
	}
}